-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core Data: Replace unnecessary fetch requests for upserting orders and order search results #14128
base: trunk
Are you sure you want to change the base?
Conversation
…shipping line taxes, order taxes
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
/// Retrieves the Stored Orders given the IDs. | ||
/// | ||
func loadOrders(siteID: Int64, orderIDs: [Int64]) -> [Order] { | ||
let predicate = NSPredicate(format: "orderID in %@", orderIDs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add the siteID
to the predicate? With the current predicate, I am afraid that we will end up loading orders from other sites with the same order ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I updated the predicate in a27533c.
@@ -66,6 +66,30 @@ final class StorageTypeExtensionsTests: XCTestCase { | |||
XCTAssertEqual(site, storedSite) | |||
} | |||
|
|||
func test_loadOrders_list_by_siteID_and_orderIDs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: We could update this test by adding an order with a different site ID other than sampleSiteID
to validate that only orders from the given siteID
are loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the test in a27533c.
Thanks @selanthiraiyan for the reviews! I addressed your comment with a commit above, this PR is ready for another look. |
Version |
Part of #14090
Description
This PR follows the suggestion in p91TBi-cl2-p2 to clean up unnecessary and expensive fetch requests made in for loops for orders including:
Steps to reproduce
Testing information
Tested with simulator iPhone 15 Pro iOS 17.4 and confirmed that order deails and order search work correctly.
All unit tests still pass.
Screenshots
N/A
RELEASE-NOTES.txt
if necessary.TODO: @itsmeichigo to update the release notes before merging.
Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: